<?php 
	$params = array();
?>
<style type="text/css">
textarea{
	width:400px;
}
</style>
<h1>INSERT PAGE</h1>

<form name="article">
<div>
<fieldset>
<legend>Insert new Article</legend>
	<p>
		Journal : 
		<select name="journal">
		<option value="">-- Please select --</option>
		<?php
			for($i=0; $i<count($journalList); $i++){
				$params = array(
						'JournalId'=>$journalList[$i]['t']['JournalId']
						, 'Title'=>$journalList[$i]['t']['Title']
						, 'TitleNative'=>$journalList[$i]['t']['TitleNative']
						, 'ISSNP'=>$journalList[$i]['t']['ISSNP']
						, 'ISSNE'=>$journalList[$i]['t']['ISSNE']
						, 'Status'=>$journalList[$i]['t']['Status']
						, 'Publisher'=>$journalList[$i]['t']['Publisher']
						, 'Contact'=>$journalList[$i]['t']['Contact']
						, 'Homepage'=>$journalList[$i]['t']['Homepage']
						);
		?>
		<option value="<?php echo base64_encode(json_encode($params)); ?>"><?php echo $journalList[$i]['t']['Title'].' ('.$journalList[$i]['t']['TitleNative'].')'; ?></option>
		<?php } ?>
		</select>
	</p>
	<p>
		Issue : 
		<select name="issue">
		<option value="">-- Please select --</option>
		<?php
			for($i=0; $i<count($issueList); $i++){
				$params = array(
						'IssueId'=>$issueList[$i]['t']['IssueId']
						, 'Year'=>$issueList[$i]['t']['Year']
						, 'CoverDate'=>$issueList[$i]['t']['CoverDate']
						, 'Volume'=>$issueList[$i]['t']['Volume']
						, 'Issue'=>$issueList[$i]['t']['Issue']
						, 'NumArticles'=>$issueList[$i]['t']['NumArticles']
						);
		?>
		<option value="<?php echo base64_encode(json_encode($params)); ?>">Year:<?php echo $issueList[$i]['t']['Year']; ?> , Volume:<?php echo $issueList[$i]['t']['Volume']; ?></option>
		<?php } ?>
		</select>
	</p>
	<p>
		Title :
		<textarea name="title" style="display:block;"></textarea>
	</p>
	<p>
		TitleNative :
		<textarea name="titlenative" style="display:block;"></textarea>
	</p>
	<p>
		Abstract :
		<textarea name="abstract" style="display:block;"></textarea>
	</p>
	<p>
		AbstractNative :
		<textarea name="abstractnative" style="display:block;"></textarea>
	</p>
	<p>
		Keyword :
		<textarea name="keyword" style="display:block;"></textarea>
	</p>
	<p>
		Author1 : 
		<select name="authors[]">
		<option value="">-- Please select --</option>
		<?php
			for($i=0; $i<count($authorList); $i++){
				$params = array(
						'AuthorId'=>$authorList[$i]['t']['AuthorId']
						,'FName'=>$authorList[$i]['t']['FName']
						,'LName'=>$authorList[$i]['t']['LName']
						,'FNameNative'=>$authorList[$i]['t']['FNameNative']
						,'LNameNative'=>$authorList[$i]['t']['LNameNative']
				);
		?>
		<option value="<?php echo base64_encode(json_encode($params)); ?>"><?php echo $authorList[$i]['t']['FName'].' '.$authorList[$i]['t']['LName'].' ('.$authorList[$i]['t']['FNameNative'].' '.$authorList[$i]['t']['LNameNative'].')'; ?></option>
		<?php } ?>
		</select>
	</p>
	<p>
		Author2 : 
		<select name="authors[]">
		<option value="">-- Please select --</option>
		<?php
			for($i=0; $i<count($authorList); $i++){
				$params = array(
						'AuthorId'=>$authorList[$i]['t']['AuthorId']
						,'FName'=>$authorList[$i]['t']['FName']
						,'LName'=>$authorList[$i]['t']['LName']
						,'FNameNative'=>$authorList[$i]['t']['FNameNative']
						,'LNameNative'=>$authorList[$i]['t']['LNameNative']
				);
		?>
		<option value="<?php echo base64_encode(json_encode($params)); ?>"><?php echo $authorList[$i]['t']['FName'].' '.$authorList[$i]['t']['LName'].' ('.$authorList[$i]['t']['FNameNative'].' '.$authorList[$i]['t']['LNameNative'].')'; ?></option>
		<?php } ?>
		</select>
	</p>
	<p>
		<input type="button" value="Submit" onclick="insertArticle();"/>
	</p>
</fieldset>
</div>
</form>

<script type="text/javascript">
	function insertArticle() {
		jQuery.post('<?php echo $this->Html->url('/Insert/insertArticle');?>',
					jQuery("form[name='article']").serialize(),
					function(data) {
						if(data.status){
// 							jAlert('Insert Complete');
							jAlert(JSON.stringify(data.message));
						}
					}, 'json');
	}
</script>